/*
 * 探究vector的两种初始化方式
 * 普通初始化 和 列表初始化
 */
/* 编译
 * g++ C++Primerlearn/STL/vectorDemo.cpp -I. -DDEBUG -fexec-charset=GBK
 */
/* 输出
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0034] --- "两个参数初始化：vector<int> vecA(4,-1)"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0036] --- "vecA[0] = -1"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0036] --- "vecA[1] = -1"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0036] --- "vecA[2] = -1"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0036] --- "vecA[3] = -1"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0041] --- "列表初始化：vector<int> vecB{4,-1}"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0043] --- "vecB[0] = 4"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0043] --- "vecB[1] = -1"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0048] --- "一个参数初始化：vector<int> vecC(4), 创建一个size()为10的vector, 并用默认构造初始化元素, int元素默认为0."
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0050] --- "vecC[0] = 0"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0050] --- "vecC[1] = 0"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0050] --- "vecC[2] = 0"
 * [Nnnut] C++Primerlearn/STL/vectorDemo.cpp:[0050] --- "vecC[3] = 0"
 */

#include <iostream>
#include <vector>
#include "CodingTraining/cpp/log/log.h"

using namespace std;

int main()
{
    int i = 0;
    vector<int> vecA(4,-1);
    LOG("两个参数初始化：vector<int> vecA(4,-1)");
    for (int val:vecA) {
        LOG("vecA[%d] = %d", i++, val);
    }

    i = 0;
    vector<int> vecB{4,-1};
    LOG("列表初始化：vector<int> vecB{4,-1}");
    for (int val:vecB) {
        LOG("vecB[%d] = %d", i++, val);
    }

    i = 0;
    vector<int> vecC(4);
    LOG("一个参数初始化：vector<int> vecC(4), 创建一个size()为10的vector, 并用默认构造初始化元素, int元素默认为0.");
    for (int val:vecC) {
        LOG("vecC[%d] = %d", i++, val);
    }

    return 0;
}


